package com.twu.biblioteca.ui.menus.movies;

import com.twu.biblioteca.items.Movie;
import com.twu.biblioteca.library.Library;
import com.twu.biblioteca.ui.menus.AbstractMenu;

/**
 * @author Alvi Jonathan Sait
 */
public class CheckoutMovieMenu extends ListMoviesMenu {

    public CheckoutMovieMenu(Library library) {
        super(library);
    }

    @Override
    public AbstractMenu handleInput(String input) {
        Movie movie = getLibrary().getMovies().get(input);
        if (movie != null && movie.isAvailable()) {
            movie.acceptCheckouter(getUser());
            return new SuccessfulMovieCheckoutMenu(getLibrary());
        }
        return new UnsuccessfulMovieCheckoutMenu(getLibrary());
    }

    @Override
    public String getUserPrompt() {
        return "Enter the Movie ID of the movie you would like to checkout:";
    }

    @Override
    protected void addMenuItems() {
        // No Menu Items needed in here since user must input the Movie ID.
    }
}
